﻿using System;
using System.Collections.Generic;
using System.Linq;
using ExpenseSystem.Common;
using ExpenseSystem.Fether;
using ExpenseSystem.Model;
using ExpenseSystem.Lor;

namespace ExpenseSystem.Fether
{
    public class DesignerBonusFetcher : NormalFetcher<DesignerBonusModel>,IDetailFetcher<DesignerBonusModel>
    {
        public DesignerBonusModel GetByCode( long site, string code, out string message)
        {
            IList<DesignerBonusModel> result = List( site, OrderBy.GetDefault(), Limit.GetDefault(), out message, out rows, Restrain.Eq("Code", code).And(Restrain.Eq("Avaliable", true)));
            if (result.Count > 0)
                return result.First();
            return null;
        }

        public IList<DesignerBonusModel> ListByMainId(long site, long mainId, out string message,out int rows)
        {
            return ListByCustomer(site,mainId,out message,out rows);
        }
        public IList<DesignerBonusModel> ListByCustomer(long site, long customer, out string message,out int rows)
        {
            IList<DesignerBonusModel> result = List(site, OrderBy.GetDefault(), Limit.GetDefault(), out message, out rows, Restrain.Eq("CustomerId", customer).And(Restrain.Eq("Avaliable", true)));
            return result;
        }
        public IList<DesignerBonusModel> ListByDesigner(long site, long customer, out string message,out int rows)
        {
            IList<DesignerBonusModel> result = List(site, OrderBy.GetDefault(), Limit.GetDefault(), out message, out rows, Restrain.Eq("DesignerId", customer).And(Restrain.Eq("Avaliable", true)));
            return result;
        }
        public IList<DesignerBonusModel> ListByOrder(long site,long order,out string message,out int rows)
        {
            IList<DesignerBonusModel> result = List(site, OrderBy.GetDefault(), Limit.GetDefault(), out message, out rows, Restrain.Eq("OrderId", order).And(Restrain.Eq("Avaliable", true)));
            return result;
        }
        public IList<DesignerBonusModel> ListByOrderDetailId(long site, long orderDetailId, out string message,out int rows)
        {
            IList<DesignerBonusModel> result = List( site, OrderBy.GetDefault(), Limit.GetDefault(), out message, out rows, Restrain.Eq("OrderDetailId", orderDetailId).And(Restrain.Eq("Avaliable", true)));
            return result;
        }
    }
}
